package com.zuoqi.easywork.system.service;

import com.zuoqi.common.utils.SessionUtil;
import com.zuoqi.easywork.system.controller.LoginController;
import com.zuoqi.easywork.system.mapper.TcOperateLogMapper;
import com.zuoqi.easywork.system.model.TcOperateLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.Date;

@Service
public class OpLogService {
    private static final Logger log = LoggerFactory.getLogger(OpLogService.class);
    @Autowired
    private  TcOperateLogMapper tcOperateLogMapper;

    public void addLog(String opUser,String opName,String remark){
        TcOperateLog tcOperateLog = new TcOperateLog();
        SimpleDateFormat tempDate = new SimpleDateFormat("yyyyMMddHHmmss");
        String datetime = tempDate.format(new Date());
        tcOperateLog.setLogId("log"+datetime);
        tcOperateLog.setOpDate(datetime);
        tcOperateLog.setOpName(opName);
        tcOperateLog.setOpUser(opUser);
        tcOperateLog.setOpRemark(remark);
        try {
            tcOperateLogMapper.insert(tcOperateLog);
        }catch (Exception e) {
            log.debug("OpLogService.addLog error");
        }

    }
}
